<?php
namespace Interf\Controller;

use Think\Controller;

class  LoadController extends Controller
{
    public function _initialize()
    {
        header("Access-Control-Allow-Origin:*");
    }
//    根据姓名性别等关键字，查出它所有的字段；
    public function index()
    {
        if (IS_POST) {
            $users = I('username');
            $pwd = I('password');

            if ($users && $pwd) {
                $User = M("user"); // 实例化User对象
                $condition['name'] = $users;
                $condition['pwd'] = $pwd;
                $result = $User->where($condition)->select();
                if (!empty($result)) {
                    echo json_encode(array("status" => "ok", "result" => '1', 'info' => '登录成功'), JSON_UNESCAPED_UNICODE);
                } else {
                    echo json_encode(array("status" => "ok", "result" => '0', 'info' => '用户名或密码错误'), JSON_UNESCAPED_UNICODE);
                }
            } else {
                echo json_encode(array("status" => "ok", "result" => '0', 'info' => '用户名或密码为空'), JSON_UNESCAPED_UNICODE);
            }
        } else {
            echo json_encode(array("status" => "ok", "result" => '0', 'info' => '未用post方法提交'), JSON_UNESCAPED_UNICODE);
        }
    }
}